<?php 
/*
 * 列表页加载文件
* @author  Sameal
* @package ixdcw
* @file    list.inc.php
*/

defined('IN_IXDCW') or exit('Access Denied');
require DT_CORE.'/'.$module.'/common.inc.php';
ViewCheck::catExists() or Prompt::listNotFound();
ViewCheck::groupListPermission() or Prompt::noPermission();
$buildBase = array('action','catid','areaid','order','gender','marriage','date','exp','education','kw');
$group=PCache::read("grouporder.php");//读取缓存会员组排序
if(!$group){
	Xd_save_groupcachefile();
}

$filter['catid']     =    getgpc('catid');
$filter['areaid']    =    getgpc('areaid');
$filter['date']      =    getgpc('date');
$filter['exp']       =    getgpc('exp');
$filter['education'] =    getgpc('education');

if (!empty($CAT)) {
	if($MOD['cat_property'] && $CAT['property']) {
		require DT_INC.'/property.func.php';
		$PPT = property_condition($catid);
	}
	unset($CAT['moduleid']);
	extract($CAT);
	//制作菜单列表
	$maincat=Xd_get_catlist($CAT,$moduleid);
} else {
	$maincat[0] = get_maincat(0, $moduleid);
}

if (!empty($ARE)) {
	$mainarea=Xd_get_arealists($ARE);
} else {
	$mainarea[0] = get_mainarea(0);
}

$areaParentid = $ARE['parentid'];

require_once DT_INC.'/post.func.php';
include load('search.lang');

if($cityid&&$cityid!=0){
	$city_order='(case when areaid IN ('.$AREA[$cityid]["arrchildid"].') then 1 else 2 end ),';
}else{
	$city_order='';
}

$vorder  = array( $MOD['order'],'addtime DESC', 'addtime ASC');
$order=isset( $order ) ? intval($order) : 0;
isset($order) && isset($vorder[$order]) or $order = 0;

$order_list=$city_order.$vorder[$order];


$date = isset($date)&&$date!=null ? intval($date) : 0;
$vdate=array('不限','今天','最近三天','最近一周','最近一个月');
$ddate=array(0,$today_endtime-1*86400,$today_endtime-3*86400,$today_endtime-7*86400,$today_endtime-30*86400);
isset($date) && isset($vdate[$date]) or $date = 0;

$exp = isset($exp)&&$exp!=null ? intval($exp) : 0;
$vexp=array('不限','1-3年','3-5年','5年以上');
$dexp=array('experience>=0','experience>=0 AND experience<=3','experience>=3 AND experience<=5','experience>=5');
isset($exp) && isset($vexp[$exp]) or $exp = 0;

//$thumb = isset($thumb) ? intval($thumb) : 0;
//$leveljob = isset($leveljob) ? intval($leveljob) : 0;


$gender = isset($gender) ? intval($gender) : 0;
$type = isset($type) ? intval($type) : 0;
$marriage = isset($marriage) ? intval($marriage) : 0;
$education = isset($education) ? intval($education) : 0;
//$experience = isset($experience) ? intval($experience) : 0;

//$minsalary = isset($minsalary) ? intval($minsalary) : 0;
//$maxsalary = isset($maxsalary) ? intval($maxsalary) : 0;

//$fromdate = isset($fromdate) && preg_match("/^([0-9]{8})$/", $fromdate) ? $fromdate : '';
//$fromtime = $fromdate ? strtotime($fromdate.' 0:0:0') : 0;
//$todate = isset($todate) && preg_match("/^([0-9]{8})$/", $todate) ? $todate : '';
//$totime = $todate ? strtotime($todate.' 23:59:59') : 0;



$tags = array();
//if($DT_QST) {
	if($kw) {
		if(strlen($kw) < $DT['min_kw'] || strlen($kw) > $DT['max_kw'])
		{ 
			Prompt::message(lang($L['word_limit'], array($DT['min_kw'], $DT['max_kw'])), getenv("HTTP_REFERER"));
		}
		if($DT['search_limit'] && $page == 1 && getenv("HTTP_REFERER")) {
			if(($DT_TIME - $DT['search_limit']) < Cookie::get('last_search')){
				Prompt::message(lang($L['time_limit'], array($DT['search_limit'])), getenv("HTTP_REFERER"));
				Cookie::set('last_search', $DT_TIME);
			}
		}
	}


	$condition = '(status=3 or status=2)';
	if($keyword) $condition .= " AND keyword LIKE '%$keyword%'";
	if($catid) $condition .= ($CAT['child']) ? " AND catid IN (".$CAT['arrchildid'].")" : " AND catid=$catid";
	if($areaid) $condition .= ($ARE['child']) ? " AND areaid IN (".$ARE['arrchildid'].")" : " AND areaid=$areaid";
	//if($thumb) $condition .= " AND thumb!=''";
	//if($vip) $condition .= " AND vip>0";
	//if($minsalary)  $condition .= " AND minsalary>$minsalary";
	//if($maxsalary)  $condition .= " AND maxsalary<$maxsalary";
	//if($fromtime) $condition .= " AND edittime>=$fromtime";
	//if($totime) $condition .= " AND edittime<=$totime";
	//if($leveljob) $condition .= " AND level=$leveljob";
			if($gender==1) $condition .= " AND NOT gender=2";
			if($gender==2) $condition .= " AND NOT gender=1";
	if($type) $condition .= " AND type=$type";
	if($marriage) $condition .= " AND marriage=$marriage";
	if($education) $condition .= " AND education>=$education";
	//if($experience) $condition .= " AND experience>=$experience";
	if($date) $condition .= " AND edittime>=$ddate[$date]";
	if($exp) $condition .= " AND $dexp[$exp]";

	$GENDER[0] = $L['all_gender'];
	$TYPE[0] = $L['all_work'];
	$MARRIAGE[0] = $L['all_marriage'];
	//$EDUCATION[0] = $L['all_education'];
	$pagesize = $MOD['pagesize'];
	$offset = ($page-1)*$pagesize;
		$do = new Job($moduleid);
		$tags = $do->getList($condition, $order_list, $DT['cache_search'] ? 'CACHE' : '');
		if($tags && $kw) {
			foreach($tags as $k=>$v) {
				$tags[$k]['title'] = str_replace($kw, '<span class="highlight">'.$kw.'</span>', $v['title']);
			}
			if($page == 1) keyword($kw, $items, $moduleid);
		}
$condition = '(status=3 or status=2)';
$condition .= ($CAT['child']) ? " AND catid IN (".$CAT['arrchildid'].")" : " AND catid=$catid";
$jobno = $db->count($db->getPre().'resume', $condition, $CFG['db_expires']);
$db->query("UPDATE {$db->getPre()}category SET jobno=$jobno WHERE catid=$catid");

$showpage = 1;
$datetype = 3;

$seo_file = 'list';
include DT_INC.'/seo.inc.php';

$template = $CAT['template'] ? $CAT['template'] : 'list';
include template($template, $module);
?>